#coding=utf-8
from django.db import models

class catalog(models.Model):
    name=models.CharField(max_length=255)
    pic=models.FileField(upload_to="image")
    parentId=models.ForeignKey("catalog")
    def __unicode__(self):
        return self.name
    def get_top_url(self):
        return "/resource/show_resource/"
    def get_first_url(self):
        return "/resource/show_leveltwo_resource/%d"%self.id
    def get_second_url(self):
        return "/resource/show_files/%d"%self.id
    def get_img_url(self):
        return "/site_media/%s"%self.pic


class tags(models.Model):
    name=models.CharField(max_length=255)
    def __unicode__(self):
        return self.name

class tagList(models.Model):
    name=models.CharField(max_length=255)
    tagId=models.ForeignKey("tags")
    def __unicode__(self):
        return self.name

class upFile(models.Model):
    name=models.CharField(max_length=255)
    datetime=models.DateTimeField()
    filepath=models.FileField(upload_to="upfile")
    filepic=models.FileField(upload_to="image")
    size=models.IntegerField()
    type=models.ForeignKey("fileType")
    user=models.CharField(max_length=50)
    def __unicode__(self):
        return self.name

class fileType(models.Model):
    name=models.CharField(max_length=255)
    pic=models.FileField(upload_to="image")
    def __unicode__(self):
        return self.name
